<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace api\user\controller;

use cmf\controller\RestUserBaseController;
use think\Db;
use think\Validate;

//审核员控制器
class AssessorController extends RestUserBaseController
{



    /**
     * 添加企业注册登记表备注
     * require project_id项目id
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     * retuen code 1
     */
    public function addRemark()
    {
        $role = $this->getUserRole();   //  获取该用户角色
        $role = '审核员';
        if ($role != '审核员') $this->error("非审核员不能添加!");

        $validate = new Validate([
            'project_id' => 'require',
            'remark_name' => 'require',
        ]);

        $validate->message([
            'project_id.require' => '请输入项目id!',
            'remark_name.require' => '请输入添加表的id!'
        ]);

        $data = $this->request->param();
        if (!$validate->check($data)) {
            $this->error($validate->getError());
        }
        $project_id = $data['project_id'];
        $remark_name = $data['remark_name'];
        unset($data['remark_name']);
        unset($data['project_id']);
        if (empty($data)) $this->error("无填写备注!");

        switch ($remark_name) {
            case '1':
                // code...
                $remark_name = 'project_register_remark';
                break;
            case '2':
                // code...
                $remark_name = 'project_condition_remark';
                break;
            case '3':
                // code...
                $remark_name = 'project_knowledge_remark';
                break;
            default:
                // code...
                break;
        }

        $data['project_id'] = $project_id;


        $id = Db::name($remark_name)->insertGetId($data);

        if (!$id) $this->error("数据异常无法添加!");


        $this->success("添加备注成功!");


    }







}
